package com.csjung.games.gamenori.client.activity;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.inject.Inject;

import com.csjung.games.gamenori.client.place.MatchingPlace;
import com.csjung.games.gamenori.client.place.WelcomePlace;
import com.csjung.games.gamenori.client.presenter.WelcomePresenter;

/**
 * A mapping of places to activities used by this application.
 */
public class AppActivityMapper implements ActivityMapper {

  private final WelcomePresenter welcomePresenter;

  public AppActivityMapper(WelcomePresenter welcomePresenter) {
    this.welcomePresenter = welcomePresenter;
  }

  public Activity getActivity(final Place place) {

    if (place instanceof WelcomePlace) {
      return new AbstractActivity() {
        @Override
        public void start(AcceptsOneWidget panel, EventBus eventBus) {
          panel.setWidget(welcomePresenter);
        }

      };
    }

    if (place instanceof MatchingPlace) {
      return new AbstractActivity() {
        @Override
        public void start(AcceptsOneWidget panel, EventBus eventBus) {
          // MatchingPresenter presenter = new MatchingPresenter(clientFactory);
          // panel.setWidget(presenter);
        }

      };
    }
    return null;
  }
}
